package com.banana.manager.forest.controller;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;

@RestController
public class PhotoController {

    @PostMapping("/addPhoto")
    public String addPhoto(@RequestParam("file") MultipartFile mf) throws IOException {
        String fileName = mf.getOriginalFilename();
        fileName = System.currentTimeMillis() +
                fileName.substring(fileName.lastIndexOf("."));
        mf.transferTo(new File("D:\\BigProject\\vuefile\\src\\assets\\indexPic\\" + fileName));
        return fileName;
    }
}
